<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<link type="text/css" href="/css/1pxtable.css" rel="Stylesheet" />	
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script>
	$(function() {
		$( "#start_date" ).datepicker({ dateFormat: "yy-mm-dd"});
		$( "#end_date" ).datepicker({ dateFormat: "yy-mm-dd"});
	});
</script>
<title>Untitled Document</title>
<style type="text/css">
#table1{
	position:absolute;
    top: 100px;
    left: 10px;
}

#table2{
	position:absolute;
    top: 100px;
    right: 10px;
}

#table3{
	position:absolute;
    top: 100px;
    left: 400px;
}
</style>
</head>

<body>
<form method = "post" action = "" enctype="multipart/form-data">
<table border="1" cellspacing="0" cellpadding="10">
	<tr>
		<td colspan = "3">Current Date: <?php echo $this->datebegin." ~ ".$this->dateEnd;?></td>
	</tr>
	<tr>
		<td>Date Start:<input name = 'start_date' id = 'start_date' type = 'text'></input></td>
		<td>Date End:<input name = 'end_date' id = 'end_date' type = 'text'></input></td>
		<td><input name = 'submit' id = 'submit' type = 'submit' value = 'submit'></input></td>
	</tr>
</table>


<div id = "table1">
<h1>Base on supplier</h1>
<table border="1" cellspacing="0" cellpadding="10">
  <tr>
    <th scope="col" style="width:100px;">Supplier</th>
    <th scope="col">Parts</th>
  </tr>
  <?php $supplier = new Model_DbTable_Suppliers();?>
  <?php foreach($this->arrFinalRes as $idSupplier => $parts){
	  		$supplierDetail = $supplier->getSupplier($idSupplier);
	 	foreach($parts as $partCode => $detail){
	  ?>
  <tr>
    <td><?php echo $idSupplier;echo "(";if($supplierDetail['title_supplier']== null){echo 'China';}else{echo $supplierDetail['title_supplier'];};echo ")";?></td>
    <td><a href="/faultyaudit/supplier-faulty-rate/date_begin/<?php echo $this->datebegin;?>/date_end/<?php echo $this->dateEnd;?>/supplier/<?php echo $idSupplier;?>/id/<?php echo $partCode;?>"><?php echo $partCode?></a><?php echo "(".count($detail).")<br />";?><input type = "hidden" value = "<?php echo $partCode?>"></input></td>
  </tr>
  <?php }}?>
</table>
    
 <?php /*  <table width="100%" border="1" cellspacing="0" cellpadding="10">
  <tr>
    <th scope="col">Shop</th>
    <th scope="col">Date</th>
    <th scope="col">Staff</th>
    <th scope="col">Comment</th>
  </tr>
  <?php foreach($detail as $key => $row){?>
  <tr>
    <td><?php echo $row[0]?></td>
    <td><?php echo $row[1]?></td>
    <td><?php echo $row[2]?></td>
    <td><?php echo $row[3]?></td>
  </tr>
  <?php }?>
</table>
*/ ?>
    </div>
    
    
    

<div id = "table2">
<h1>Base on parts</h1>
<table border="1" cellspacing="0" cellpadding="10"> 
	<tr>
		<th>Parts</th>
		<th colspan="2">Supplier1</th>
		<th colspan="2">Supplier2</th>
		<th colspan="2">Supplier3</th>
		<th colspan="2">Supplier4</th>
	</tr>
		<?php foreach($this->arrFinalRes2 as $k => $v){
		?>
			
	<tr>
		<td><?php echo $k;?></td>
			<?php foreach($v as $k2 => $v2){
				$supplierDetail = $supplier->getSupplier($k2);?>
				<td><?php if($supplierDetail['title_supplier']== null){echo 'China';}else{echo $supplierDetail['title_supplier'];};?></td>
				<td><?php echo $k2."(".count($v2).")";?></td>
	<?php	} ?>
	</tr>
	<?php }?>
</table>
</div>


<div id = "table3" <?php if($this->myList == null){?> visibility: hidden<?php }?>>
<h1>Detail</h1>
	<table border="1" cellspacing="0" cellpadding="10">
		<tr>
			<th scope="col">Shop</th>
   			<th scope="col">Date</th>
      		<th scope="col">Staff</th>
    		<th scope="col">Comment</th>
		</tr>
	<?php foreach($this->myList as $k3 => $v3){?>
		<tr>
			<td><?php echo $v3['shopcode_faulty']?></td>
   			<td><?php echo $v3['date_faulty']?></td>
    		<td><?php echo $v3['staff_name_faulty']?></td>
    		<td width = "200px"><?php echo $v3['comment_faulty']?></td>
		</tr>
		<?php 		
	 			
	 		}?>
	</table>
</div>
</form>
</body>

</html>
